package day0725API;

import java.io.*;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;

public class Test10 {
    public static void main(String[] args) throws IOException {

        FileFilter filter=new FileFilter() {
            public boolean accept(File file) {
                return file.getName().endsWith(".txt");
            }
        };

        File  f=new File("G:/");
        File[] fs=f.listFiles(filter);
        for(File file: fs){
            try(FileInputStream fis=new FileInputStream(file);
                InputStreamReader isr=new InputStreamReader(fis,"GBK")
                //InputStreamReader isr=new InputStreamReader(fis, StandardCharsets.UTF_8)
            ){
                int data=-1;
                while(  (data=isr.read())!=-1){
                    System.out.print((char)data);
                }
            }catch (IOException e){
                e.printStackTrace();
            }
        }



    }
}